package com.xiaojiu.mvp.presenter;
import com.xiaojiu.base.BasePresenter;
import com.xiaojiu.base.BaseSubscriber;
import com.xiaojiu.bean.PuBuLiuModel;
import com.xiaojiu.mvp.constant.MvpTag;
import com.xiaojiu.mvp.contract.LoginContract;
import com.xiaojiu.mvp.model.LoginModelImpl;

/**
* Created by Jacky on 2017/03/17
*/

public class LoginPresenterImpl extends BasePresenter<LoginContract.View> implements LoginContract.Presenter{

    private LoginContract.Model  mModel;

    public LoginPresenterImpl(){

        mModel = new LoginModelImpl();

    }

    @Override
    public void getLogin1(String account, String pass) {
        mSubscription = doSubscribe(mModel.getLogin(account, pass), new BaseSubscriber<PuBuLiuModel>(mContext, true) {
            @Override
            protected void _onNext(PuBuLiuModel result) {

                mView.onRegister(result);
            }

            @Override
            protected void _onError() {
                mView.onError(MvpTag.TAG1);
            }
        });
    }

    @Override
    public void getRegister2(String account, String pass) {
        mSubscription = doSubscribe(mModel.getLogin(account, pass), new BaseSubscriber<PuBuLiuModel>(mContext, true) {
            @Override
            protected void _onNext(PuBuLiuModel result) {

                mView.onRegister(result);
            }

            @Override
            protected void _onError() {
                mView.onError(MvpTag.TAG2);
            }
        });
    }

    @Override
    public void getVerification3(String account, String pass) {
        mSubscription = doSubscribe(mModel.getLogin(account, pass), new BaseSubscriber<PuBuLiuModel>(mContext, true) {
            @Override
            protected void _onNext(PuBuLiuModel result) {

                mView.onRegister(result);
            }

            @Override
            protected void _onError() {
                mView.onError(MvpTag.TAG3);
            }
        });
    }
}